package basics.test;

import basics.annotation.AParameter;
import basics.annotation.Actioner;
import basics.annotation.Service;
import basics.scanner.factory.ActionHandleFactory;

import java.util.HashMap;
import java.util.Map;


/**
 * @author Ldanniel
 * @description :
 * @date 2022/11/01 22:33
 * @since open jdk 1.8
 */
@Service
public class Demo {

    @Actioner(action="one")
    public void fun() {
        System.out.println("执行无参的fun方法");
    }

    @Actioner(action="two")
    public void fun(Map<String,Object> parameter) {

        System.out.println("执行单参的fun方法： parameter = " + parameter);
    }

    @Actioner(action="three")
    public void fun(@AParameter(name="one")int one,
                    @AParameter(name="two")String two,
                    @AParameter(name="three")boolean three) {
        System.out.println("执行三参的fun方法： one = " + one + " two = " + two + " three = " + three);
    }

    private static class Student {
        private String name;
        private int age;
        private boolean sex;

        private Student(String name, int age, boolean sex) {
            this.name = name;
            this.age = age;
            this.sex =sex;
        }

        @Override
        public String toString() {
            return "name = " + name + ", age = " + age + ", sex = " + (sex ? "男" : "女");
        }
    }

    @Actioner(action="four")
    public void fun(@AParameter(name="1")Student student) {
        System.out.println("执行复杂类型参数的fun方法 ：" + student);
    }

    public static void main(String[] args) throws Exception {
        // 扫描包，这里直接扫描Demo所在的包
//        ActionFactory.newInstance().scanAction(Demo.class);
//
//        Addition addition = new Addition();
//
//        addition.doRequest("one", null);
//
//        addition.doRequest("two", new ArgumentMaker()
//                .add("1", 3)
//                .toOgnl());
//
//        addition.doRequest("three",new ArgumentMaker()
//                .add("3", true)
//                .add("1", 3)
//                .add("2", "这是第二个参数")
//                .toOgnl());
//
//        Student student = new Student("小明", 15, true);
//        addition.doRequest("four", new ArgumentMaker().add("1", student).toOgnl());

    }

}